package main

import (
	"flag"
	"fmt"
	"maze_wasm/openbrowser"
	"net/http"
)

var (
	port uint
	path string
)

func init() {
	flag.UintVar(&port, "port", 9090, "port")
	flag.StringVar(&path, "path", ".", "local relative or absolute path")

	flag.Parse()
}

func main() {
	http.Handle("/", http.FileServer(http.Dir(path)))

	fmt.Println("Server is starting...")
	uri := fmt.Sprintf("http://localhost:%d", port)
	fmt.Printf("服务已开启, 浏览器打开: %s\n", uri)
	openbrowser.OpenBrowser(uri)
	fmt.Println("ListenAndServe:", http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}
